package wusiyuan.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.alibaba.fastjson.JSON;

import dao.impl.CountyDaoImpl;
import entity.City;
import entity.County;

/**
 * Servlet implementation class CountyShowServlet
 */
public class CountyShowServlet extends HttpServlet {
	private CountyDaoImpl cdi = new CountyDaoImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setCharacterEncoding("utf-8");
		HttpSession session = request.getSession(); 
		Object object = session.getAttribute("district");		
		int i = Integer.parseInt(object.toString());	
		County county = cdi.getCountyByCountyId(i);
		response.getWriter().print(JSON.toJSONString(county));
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		doGet(request, response);
	}

}
